/*
 *    Copyright (c) 2018-2025, proj All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 *
 * Redistributions of source code must retain the above copyright notice,
 * this list of conditions and the following disclaimer.
 * Redistributions in binary form must reproduce the above copyright
 * notice, this list of conditions and the following disclaimer in the
 * documentation and/or other materials provided with the distribution.
 * Neither the name of the proj developer nor the names of its
 * contributors may be used to endorse or promote products derived from
 * this software without specific prior written permission.
 * Author: proj
 */

package com.ykht.proj.coupon.controller.b;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.ykht.proj.common.core.util.R;
import com.ykht.proj.common.security.util.SecurityUtils;
import com.ykht.proj.coupon.Enum.LookRoleTypeEnum;
import com.ykht.proj.coupon.Enum.UserTypeEnum;
import com.ykht.proj.coupon.entity.CnBrand;
import com.ykht.proj.coupon.entity.CnShop;
import com.ykht.proj.coupon.entity.FxShopMoneyFlow;
import com.ykht.proj.coupon.entity.FxWaiterExt;
import com.ykht.proj.coupon.service.CnUserExtService;
import com.ykht.proj.coupon.service.FxShopMoneyFlowService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;


/**
 * 门店资金流水
 *
 * @author proj code generator
 * @date 2021-02-01 19:00:17
 */
@RestController
@AllArgsConstructor
@RequestMapping("b/flow")
@Api(value = "fxshopmoneyflow", tags = "b端门店相关流水")
public class BxShopMoneyFlowController {

	private final FxShopMoneyFlowService fxShopMoneyFlowService;
	private final CnUserExtService cnUserExtService;


	@ApiOperation(value = "充值记录", notes = "充值记录")
	@GetMapping("/rechargeRecord")
	public R rechargeRecord() {
		Integer userType = SecurityUtils.getUser().getUserType();
		if (UserTypeEnum.brand.getValue().equals(userType)){
			CnBrand cnBrand = new CnBrand().selectById(SecurityUtils.getSjId());
			return R.ok(fxShopMoneyFlowService.show(cnBrand));
		}
		if (UserTypeEnum.shop.getValue().equals(userType)){
			CnShop cnShop = new CnShop().selectById(SecurityUtils.getSjId());
			return R.ok(fxShopMoneyFlowService.showCnShop(cnShop));
		}
		return R.failed();
	}

	@ApiOperation(value = "充值列表", notes = "充值列表")
	@GetMapping("/rechargeItem")
	public R rechargeItem(FxShopMoneyFlow fxShopMoneyFlow) {
		CnBrand cnBrand = new CnBrand().selectById(SecurityUtils.getSjId());
		return R.ok(fxShopMoneyFlowService.rechargeItem(cnBrand, fxShopMoneyFlow));
	}

}
